Skip to content

Connection drop nodes on the canvas, SecsGemBase 1.0.0-build-0029 - #15

Merged
Prengemann merged 1 commit into
mainfrom
feature/25-verbindungsabbruch
Nov 16, 2026
Merged

Prengemann merged 1 commit into
mainfrom
feature/25-verbindungsabbruch

Conversation

@Prengemann

Copy link
Copy Markdown
Contributor

Why

A customer wants to see how their side copes with a lost connection at a defined moment, for example right after an S6F11 with a certain CEID (internal board, issue 25). Until now a connection could only be closed by hand with the Connect button: about a second late and as an orderly close.

The SecsGemBase engine has the two nodes for this since 1.0.0-build-0027. This PR brings them into the app.

Changes

  • Packages: SecsGemBase.MessageHandling and SecsGemBase.ScenarioEngine from 1.0.0-build-0018 to 1.0.0-build-0029. The app builds against them unchanged. They also bring the reconnect fixes made for this feature, and the Wait node's warning for a time it cannot read.
  • Two nodes on the canvas, with palette chips DROP CONNECTION and WAIT FOR COMM.:
    • Drop connection aborts the connection with a TCP reset. Its value is the downtime in ms (default 5000); with 0 a new connection is set up right away.
    • Wait for communication waits until HSMS is selected and communication is established. Its value is the timeout in ms (default 20000); with 0 it waits as long as the run may take.
    • Both have a success and a failure output, their own colour, and a title that shows the value ("Drop connection · 5000 ms", "Wait for communication · max 20000 ms") or what is wrong with it.
  • Editor: NodeMillisecondsViewModel.For gives the editor for the three node types with a time in ms. For the two new ones 0 is allowed, and the hint says what it does.
  • Connect button: disabled while a Drop connection node keeps the port closed. A click would open the port in the middle of the downtime. Services/PortHold keeps track per run; the end of a run releases its holds.
  • Wait node: WaitTime.TryRead reads with the invariant culture only, as the engine does since 1.0.0-build-0029. The shared text helpers moved to NodeMilliseconds.
  • Docs:
    • README: new section "Simulating a connection loss" with a typical scenario and what to expect.
    • specification/features.md: new section. specification/secsgembase_library.md: the bullet on the client loop described the old packages.

Known limits

  • Not a pulled cable. The drop is a TCP reset: the other side learns at once that the connection is gone. A silent loss needs a firewall rule or a TCP proxy.
  • Outage on the passive side. The connection comes back with the next attempt of the active side, after a refused attempt its T5 later (10 s by default). The outage lasts exactly the downtime only when this instance is the active side.
  • 0 ms against another instance of this app. In the run below the immediate reconnect was refused once, because the passive instance needed a moment to listen again; the connection was back after T5.
  • Library auto-replies. While a scenario with a Receive node runs, the library does not answer that node's Stream/Function, whatever the condition (internal SecsGemBase issue 47). The reply has to be sent in the scenario.
  • No unit test for the wiring in the view models. ScenariosViewModel and MainViewModel cannot be constructed in tests (internal issue 39). OpenNodeEditor, the tracking in RunOnceAsync, CanConnect and the XAML are covered by the run in the app only.
  • CLAUDE.md and AGENTS.md are not touched. Both have an uncommitted rewrite in the owner's checkout. Outdated there after this PR: the pinned version in the example, the line reference CommunicationHandler.cs:187 (now 376), and the Scenarios section lacks the two nodes.
  • Tooltip under Wine. In an earlier variant the Connect button's tooltip text changed while the tooltip was open; that ended the app under Wine with an X11 error. The tooltip text is fixed now. Not analysed further, and not seen on Windows.

Verification

  • Build and tests: Linux SDK, Release build of app and tests with 0 warnings, 0 errors, against the packages from nuget.org. Tests under Wine with Windows .NET: 143/143 pass.
  • New tests: 61 new test cases in ConnectionNodeTests, PortHoldTests, NodeMillisecondsViewModelTests, WaitNodeTests and ScenarioRunTests.
  • Counter-checks: 31 mutations, each applied alone; every one turns the matching tests red:
    • no failure output (each node)
    • no title (each node)
    • no palette default (each node), defaults swapped
    • value read like a Wait node, without trimming, with the computer's culture
    • timeout 0 shown as a number
    • hidden characters not shown (each node)
    • missing value shown as invalid
    • editor minimum 1 (each node), Wait editor allows 0
    • editor without the hint on 0
    • For without Drop connection, with the two editors swapped, with an editor for every node type
    • port hold never active, for every state, also for Running
    • end of a run releases nothing, releases everything
    • late report not ignored
    • one report releases every node of the run
    • one report releases the same node id of another run
    • snapshot looks the value up in the library
    • Wait title read with the computer's culture
  • Run in the real app (Wine, two instances on a linked endpoint, Active and Passive, final state of this branch unless noted):
    • Drop 3000 ms on the active side: reset, port closed, the passive side logs the reset and is selected again 3.0 s later; Wait for communication succeeds about 1 s after that; S1F1 is sent; the run completes.
    • Run timeout during the downtime: the port opens at once, and the node keeps no hourglass.
    • Earlier state of the branch (the code these cases use is unchanged since, except the tooltip and the hourglass):
      • Drop without a connection follows the failure output; an invalid value fails the run with the engine's message.
      • Drop 0 ms on the active side: first attempt refused, back after T5.
      • Drop 2000 ms on the passive side after a received S1F1: back when the active side tries again (T5).
      • Cancel during the downtime and stopping a loop during the downtime: the port opens at once.
      • Connect button disabled during the downtime on both sides, enabled again afterwards, also with the mouse over it.
      • Both editors show their texts; both chips make a node with its default.
  • Independent review: four lenses (node view models and editor, port hold and Connect lock, package bump, written claims), every finding checked by a second agent. No defect in the code paths; six low findings (docs, a comment, a test gap, the hourglass), all applied. The reviewers also compared the titles with the engine's parser over about 8 million inputs and confirmed with the published packages that the DI container passes both handlers to the engine.
  • Not tested on Windows itself; CI runs the build and tests on windows-latest. Open for a manual check on Windows: does the reset arrive, can the port be bound again at once, are the times right.

🤖 Generated with Claude Code

A scenario can now drop the HSMS connection at a chosen point, keep the
port closed for a time and go on when communication is back (customer
request: simulate a connection loss after an event).

- Packages: SecsGemBase.MessageHandling and SecsGemBase.ScenarioEngine
  from 1.0.0-build-0018 to 1.0.0-build-0029. The engine executes the
  nodes DropConnection and WaitForCommunication; the packages also bring
  the reconnect fixes made for this feature.
- Canvas: palette chips DROP CONNECTION and WAIT FOR COMM. Both nodes
  have a success and a failure output, their own colour and a title that
  shows the value ("Drop connection · 5000 ms", "Wait for communication ·
  max 20000 ms") or what is wrong with it.
- Editor: NodeMillisecondsViewModel.For gives the editor for the three
  node types with a time in ms. For the two new ones 0 is allowed, and
  the hint says what it does.
- Connect button: disabled while a Drop connection node keeps the port
  closed (Services/PortHold, ScenariosViewModel.PortClosedByScenario).
  A click would open the port in the middle of the downtime.
- WaitTime.TryRead reads with the invariant culture only, as the engine
  does since 1.0.0-build-0029. The shared text helpers moved to
  NodeMilliseconds.
- README: section "Simulating a connection loss" with what to expect.
  specification/features.md: new section.

New tests: ConnectionNodeTests, PortHoldTests, more cases in
NodeMillisecondsViewModelTests, WaitNodeTests and ScenarioRunTests
(61 new cases).

Internal board: secsgem/evencoolerfastsim issue 25.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Prengemann
Prengemann merged commit 6db2142 into main Nov 16, 2026
1 check passed
@Prengemann
Prengemann deleted the feature/25-verbindungsabbruch branch November 16, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant